﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Enterprise.Infrastructure;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.Model.WorkFlow;
using Enterprise.DataFactory;
namespace Enterprise.Data.WorkFlow
{
    /// <summary>
    ///  流程处理过程记录
    /// </summary>
    public class WorkFlowProcessData
    {
        /// <summary>
        ///  流程处理过程记录数据列表
        /// </summary>
        /// <returns></returns>
        public List<WorkFlowProcessEntity> WorkFlowProcessList()
        {
            List<WorkFlowProcessEntity> list = new List<WorkFlowProcessEntity>();
            string cmd = "Select * from SYS_WORKFLOWPROCESS";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                WorkFlowProcessEntity entity = new WorkFlowProcessEntity();
                if (!Convert.IsDBNull(dr["PID"])) entity.PID = Convert.ToString(dr["PID"]);
                if (!Convert.IsDBNull(dr["WFID"])) entity.WFID = Convert.ToString(dr["WFID"]);
                if (!Convert.IsDBNull(dr["PWFTYPE"])) entity.PWFTYPE = Convert.ToInt32(dr["PWFTYPE"]);
                if (!Convert.IsDBNull(dr["PUSERID_REAL"])) entity.PUSERID = Convert.ToInt32(dr["PUSERID_REAL"]);
                if (!Convert.IsDBNull(dr["PUSERID"])) entity.PUSERID = Convert.ToInt32(dr["PUSERID"]);
                if (!Convert.IsDBNull(dr["PISCHECK"])) entity.PISCHECK = Convert.ToInt32(dr["PISCHECK"]);
                if (!Convert.IsDBNull(dr["PRESULT"])) entity.PRESULT = Convert.ToInt32(dr["PRESULT"]);
                if (!Convert.IsDBNull(dr["PREMARK"])) entity.PREMARK = Convert.ToString(dr["PREMARK"]);
                if (!Convert.IsDBNull(dr["PTIME"])) entity.PTIME = Convert.ToDateTime(dr["PTIME"]);
                if (!Convert.IsDBNull(dr["PUSERORDERBY"])) entity.PUSERORDERBY = Convert.ToInt32(dr["PUSERORDERBY"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 流程数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void WorkFlowProcessExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }

        /// <summary>
        /// 返回数据集合
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public DataSet ExcuteDataSet(string cmd)
        {
            return DbExecute.GetDataSet(cmd);
        }
    }
}
